package cadc.ping;

import cadc.actions.UserAction;
import cadc.daos.GroupDao;
import cadc.models.WorkSet;

@SuppressWarnings("serial")
public class ListWorks extends UserAction {
	private static String[] typenames = {"学习平台->学习交流网站",
		"学习平台->数据库管理系统",
		"学习平台->CAI教学课件",
		"学习平台->虚拟实验平台",
		"媒体设计->平面设计",
		"媒体设计->动画设计",
		"媒体设计->虚拟设计(人物、场景等)",
		"媒体设计->DV短剧",
		"媒体设计->电子杂志",
		"媒体设计->其他",
		"电子音乐->电子音乐",
		"媒体制作设计类->中华民族文化组"};
	private WorkSet workSet;
	private GroupDao groupDao;
	private int workType;
	public String execute(){
		if(workType<0||workType>typenames.length){
			this.addActionError("不存在该类别作品");
			return ERROR;
		}
		workSet = new WorkSet();
		workSet.setWorkType(workType);
		workSet.setTypeName(typenames[workType]);
		workSet.setGroupList(groupDao.listWorks(workType, super.getAccount().getId()));
		return SUCCESS;
	}
	public WorkSet getWorkSet() {
		return workSet;
	}
	public void setWorkSet(WorkSet workSet) {
		this.workSet = workSet;
	}
	public GroupDao getGroupDao() {
		return groupDao;
	}
	public void setGroupDao(GroupDao groupDao) {
		this.groupDao = groupDao;
	}
	public int getWorkType() {
		return workType;
	}
	public void setWorkType(int workType) {
		this.workType = workType;
	}
	public int getType(){
		if((workType>3&&workType<10)||workType==11)return 5;
		if(workType==10)return 6;
		else return workType+1;
	}
}
